import request from "./request";

class Http {
  // 私有的
  private baseUrl: string;
  constructor(baseUrl: string = "") {
    this.baseUrl = baseUrl;
  }

  get<T>(url: string, data: Object = {}) {
    return request<T>({
      method: "GET",
      url: this.baseUrl + url,
      data,
    });
  }
  post<T>(url: string, data: Object = {}) {
    return request<T>({
      method: "POST",
      url: this.baseUrl + url,
      data,
    });
  }
  put<T>(url: string, data: Object = {}) {
    return request<T>({
      method: "PUT",
      url: this.baseUrl + url,
      data,
    });
  }
  delete<T>(url: string, data: Object = {}) {
    return request<T>({
      method: "DELETE",
      url: this.baseUrl + url,
      data,
    });
  }
}

export default Http;
